"""
工业通信驱动框架包
================

该包提供了多种工业通信协议的实现，包括：
- 现场总线协议：Modbus, Profinet, CANopen, EtherCAT, DeviceNet, BACnet, S7
- 工业以太网协议：Ethernet/IP, OPC UA
- 标准通信协议：串口, Socket, HTTP, WebSocket

主要模块：
- core: 核心接口和工厂类
- config: 配置管理
- protocols: 各协议实现
- utils: 工具模块

系统会在导入时自动加载默认配置文件并创建所有通信和设备实例，
其他项目可以直接使用而无需额外操作。
"""

import os

# 为方便使用，导入主要的类
from .core.communication_interface import CommunicationInterface, CommunicationProtocol
from .core.device_interface import DeviceInterface
from .core.protocol_factory import ProtocolFactory
from .core.device_manager import get_device_manager, DeviceManager
from .core.config_manager import get_config_manager, ConfigManager
from .core.communication_manager import get_communication_manager, CommunicationManager
from .config.address_manager import get_device_address_manager,DeviceAddressMapping,JsonObject,load_mapping_from_file
from .driver_manager import DriverManager, get_driver_manager, load_drivers
from .protocols.industrial_networks.opcua.opcua_interface import OpcUaInterface
from .protocols.industrial_networks.opcua.opcua_interface_param import get_opcua_param_manager, OpcUaParamManager, OpcUaICommandType
from .readwrite.typedef import DataType
from .protocols.standard.socket.socket_interface import SocketInterface
from .utils.logger import get_logger,setup_logger,LoggerManager

# 导出全局访问函数，方便直接获取管理器实例
try:
    config_manager = get_config_manager()
    communication_manager = get_communication_manager()
    device_manager = get_device_manager()
    device_address_manager = get_device_address_manager()
    opcua_param_manager = get_opcua_param_manager()
except Exception as e:
    logger = get_logger(__name__)
    logger.error(f"Failed to initialize global manager instances: {e}")
    config_manager = None
    communication_manager = None
    device_manager = None
    device_address_manager = None
    opcua_param_manager = None

__all__ = [
    "CommunicationInterface",
    "CommunicationProtocol",
    "DeviceInterface",
    "OpcUaInterface",
    "OpcUaParamManager",
    "opcua_param_manager",
    "get_opcua_param_manager",
    "OpcUaICommandType",
    "ProtocolFactory",
    "DeviceManager",
    "get_device_manager",
    "ConfigManager",
    "get_config_manager",
    "CommunicationManager",
    "get_communication_manager",
    "DriverManager",
    "get_driver_manager",
    "load_drivers",
    "config_manager",
    "communication_manager",
    "device_manager",
    "device_address_manager",
    "DeviceAddressMapping",
    "get_device_address_manager",
    "JsonObject",
    "load_mapping_from_file",
    "DataType",
    "get_logger",
    "setup_logger",
    "LoggerManager"
]

# 提供版本信息
__version__ = "1.0.0"